package org.example.controller;

import jakarta.annotation.Resource;
import org.example.annotation.Auth;
import org.example.annotation.EnableAutoRegister;
import org.example.controller.service.CommService;
import org.example.pojo.Respond;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/app")
@EnableAutoRegister
public class CommController {

    @Resource
    private CommService commService;

    @Auth(enable = false,token = false,level = 1,roles = {"visitor","admin"})
    @GetMapping("/test")
    public Respond<String> test(){
        return commService.test();
    }

    @Auth(enable = true,token = true,level = 1,roles = {"vip","superAdmin"},authType = 1)
    @GetMapping("/authSuccess")
    public Respond<String> authSuccess(){
        return Respond.creatAuthSuccessRespond("这是AppCopy","鉴权成功");
    }

    @Auth(enable = true,token = true,level = 1,roles = {"visitor","admin"})
    @GetMapping("/authFail")
    public Respond<String> authFail(){
        return Respond.creatAuthFailRespond("这是AppCopy","鉴权失败");
    }
}
